package com.topisv.tms.utils.io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class ReaderXML {

	public static Element read(String path) {

		SAXReader reader = new SAXReader();
		FileInputStream file = null;
		try {
			file = new FileInputStream(getPath(path));
			Document d = reader.read(file);
			return d.getRootElement();
		} catch (DocumentException e) {
			
		} catch (FileNotFoundException e) {
			
		} finally {
			if (file != null) {
				try {
					file.close();
				} catch (IOException e) {
					
				}
			}
		}
		return null;
	}

	public static String getPath(String path) {
		return ReaderXML.class.getClassLoader().getResource(path).getPath();
	}
}